package store.service;

import store.domain.Account;
import store.persistence.AccountDao;
import store.persistence.impl.AccountDaoImpl;

public class AccountService {

    private AccountDao accountDao;
//    private SearchDao searchDao = new SearchDaoImpl();
    public AccountService() {
        this.accountDao = new AccountDaoImpl();
    }

    public Account getAccount(String username, String password) {
        Account account = new Account();
        account.setUsername(username);
        account.setPassword(password);
        return accountDao.getAccountByUsernameAndPassword(account);
    }
    public void insertAccount(Account account) {
        accountDao.insertAccount(account);
        accountDao.insertProfile(account);
        accountDao.insertSignon(account);
    }

    public void updateAccount(Account account) {
        accountDao.updateAccount(account);
        accountDao.updateProfile(account);

        if (account.getPassword() != null && account.getPassword().length() > 0) {
            accountDao.updateSignon(account);
        }
    }
//    public void deleteAccount(String username) {
//            accountDao.deleteAccount(username);
//    }
//public List<Record> searchRecord(String username){
//    return searchDao.searchRecord(username);
//}
}
